package top.itbook.pojo;

import top.itbook.shop.Armor;
import top.itbook.shop.Arms;

import java.io.Serializable;

/**
 * 用户类 - 定义用户属性
 * 为了实现本地化缓存机制，使用对象序列化方式进行保存
 */
public class User implements Serializable {
    // 申明序列化版本号码
    private static final long serialVersionUID = 1;

    private int id; // 用户序号 - 数据库使用自增
    private String regIP; // 注册时所处IP
    private String ip; // （当前）登录IP地址
    private String backIP; // 上一次登录IP

    // 唯一身份验证标识
    private String account; // 账号
    private String password; // 密码
    private String username; // 用户名
    private String registrationDate; // 注册日期
//    private String[] bag; // 背包
    private String encryption; // 该用户目前所使用的密码加密算法 若用户修改密码则默认修改为最新的算法

    private String group; // 所在用户组 - 权限等级
    private int gold; // 金币
    private int countingCoupons; // 点券
    private int grade; // 等级

    private int blood; // 血量
    private int attack; // 攻击值
    private int defense; // 防御值
    private int mana; // 灵力值

    private Arms weaponBar; // 当前武器栏
    private Armor ArmourFence; // 当前防具栏

    // 构造器 - 无参
    public User() {
    }

    // 构造器 - 有参
    public User(int id,String account,String password,String username,String group){
        this.id = id;
        this.account = account;
        this.password = password;
        this.username = username;
        this.group = group;
        this.grade = 1;
        this.attack = 10;
        this.defense = 10;
        this.mana = 0;
        this.blood = 100;
    }

    public String getEncryption(){
        return encryption;
    }

    public void setEncryption(String encryption){
        this.encryption = encryption;
    }

    public Armor getArmourFence(){
        return ArmourFence;
    }

    public void setArmourFence(Armor armourFence){
        this.ArmourFence = armourFence;
    }

    public void setRegIP(String regIP){
        this.regIP = regIP;
    }

    public void setWeaponBar(Arms arms){
        this.weaponBar = arms;
    }

    public Arms getWeaponBar(){
        return weaponBar;
    }

    public int getBlood() {
        return blood;
    }

    public void setBlood(int blood) {
        this.blood = blood;
    }

    public int getMana() {
        return mana;
    }

    public void setMana(int mana) {
        this.mana = mana;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public void setGrade(int grade) {
        this.grade = grade;
    }

    public int getAttack() {
        return attack;
    }

    public void setAttack(int attack) {
        this.attack = attack;
    }

    public int getDefense() {
        return defense;
    }

    public void setDefense(int defense) {
        this.defense = defense;
    }

    public int getId(){
        return id;
    }

    public String getAccount(){
        return account;
    }

    public String getPassword(){
        return password;
    }

    public String getUsername(){
        return username;
    }

    public String getGroup(){
        return group;
    }

    public int getGrade(){
        return grade;
    }

    public int getGold(){
        return gold;
    }

    public int getCountingCoupons(){
        return countingCoupons;
    }

    public String getRegistrationDate(){
        return registrationDate;
    }

    public void setId(int id){
        this.id = id;
    }

    public void setUsername(String username){
        this.username = username;
    }

    public void setGroup(String group){
        this.group = group;
    }

    public void setGold(int gold){
        this.gold = gold;
    }

    public void setCountingCoupons(int countingCoupons){
        this.countingCoupons = countingCoupons;
    }

    public void setPassword(String password){
        this.password = password;
    }

    public void setRegistrationDate(String registrationDate){
        this.registrationDate = registrationDate;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", account='" + account + '\'' +
                ", password='" + password + '\'' +
                ", username='" + username + '\'' +
                ", group='" + group + '\'' +
                ", gold=" + gold +
                ", countingCoupons=" + countingCoupons +
                ", grade=" + grade +
                ", blood=" + blood +
                ", attack=" + attack +
                ", defense=" + defense +
                ", mana=" + mana +
                '}';
    }
}
